<?php
include_once "inc/docroot.php";


    include_once(PATH."common/base.php");
    $pageTitle = "Verify Your Account";
    include_once(PATH."common/header.php");

    if(isset($_GET['v']) && isset($_GET['e']))
    {
        include_once PATH."inc/class.users.inc.php";
        $users = new ColoredListsUsers($db);
        $ret = $users->verifyAccount();
    }
    elseif(isset($_POST['v']))
    {
        include_once PATH."inc/class.users.inc.php";
        $users = new ColoredListsUsers($db);
        $ret = $users->updatePassword();
		if($ret == TRUE):
			echo "Redirecting to <a href=http://localhost/bytefact/index.php>http://localhost/bytefact/index.php</a>";
			header("Location: index.php");
        	exit;
		else:
			$ret[0] = -1;
			echo "Passwords didn;t match";
		endif;
		
    }
    else
    {
        header("Location: signup.php");
        exit;
    }

    if(isset($ret[0])):
        if($ret[0]<3):
?>

        <h2>Choose a Password</h2>

        <form method="post" action="accountverify.php">
            <div>
                <label for="p">Choose a Password:</label>
                <input type="password" name="p" id="p" /><br />
                <label for="r">Re-Type Password:</label>
                <input type="password" name="r" id="r" /><br />
                <input type="hidden" name="v" value="<?php echo $_GET['v'] ?>" />
                <input type="submit" name="verify" id="verify" value="Verify Your Account" />
            </div>
        </form>

<?php
        endif;
    endif;

    include_once(PATH."common/ads.php");
    include_once(PATH."common/close.php");
?>